/**
 *  Document   : Price
 *  Created on : 17 juil. 2008, 10:21:34
 *  Author     : Rivo
 */

package gla.centralhotel.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;


@Entity
@Table(name = "price")
@NamedQueries({@NamedQuery(name = "Price.findById", query = "SELECT p FROM Price p WHERE p.id = :id"),
@NamedQuery(name = "Price.findByPeriodStart", query = "SELECT p FROM Price p WHERE p.periodStart = :periodStart"),
@NamedQuery(name = "Price.findByPeriodEnd", query = "SELECT p FROM Price p WHERE p.periodEnd = :periodEnd"),
@NamedQuery(name = "Price.findByPrice", query = "SELECT p FROM Price p WHERE p.price = :price")})
public class Price implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "id", nullable = false)
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Integer id;
    @Column(name = "period_start", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date periodStart;
    @Column(name = "period_end", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date periodEnd;
    @Column(name = "price", nullable = false)
    private float price;
    @JoinColumn(name = "ref_room", referencedColumnName = "id")
    @ManyToOne
    private Room refRoom;

    public Price() {
    }

    public Price(Integer id) {
        this.id = id;
    }

    public Price(Integer id, Date periodStart, Date periodEnd, float price) {
        this.id = id;
        this.periodStart = periodStart;
        this.periodEnd = periodEnd;
        this.price = price;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getPeriodStart() {
        return periodStart;
    }

    public void setPeriodStart(Date periodStart) {
        this.periodStart = periodStart;
    }

    public Date getPeriodEnd() {
        return periodEnd;
    }

    public void setPeriodEnd(Date periodEnd) {
        this.periodEnd = periodEnd;
    }

    public float getPrice() {
        return price;
    }

    public void setPrice(float price) {
        this.price = price;
    }

    public Room getRefRoom() {
        return refRoom;
    }

    public void setRefRoom(Room refRoom) {
        this.refRoom = refRoom;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Price)) {
            return false;
        }
        Price other = (Price) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "gla.centralhotel.model.Price[id=" + id + "]";
    }

}
